<template>
  <el-container class="container">
    <el-header class="header">
      <el-row>
        <el-col :span="4">
          <div class="grid-content bg-purple">
            <img
              src="https://cn.vuejs.org/images/vuemastery.png"
              style="width:150px;heigh:200px;"
            /></div
        ></el-col>
        <el-col :span="16">
          <div class="middle">
            电商后台管理系统
          </div>
        </el-col>
        <el-col :span="4">
          <div class="loginout">
            <a href="#" @click="loginout">退出</a>
          </div>
        </el-col>
      </el-row>
    </el-header>
    <el-container>
      <el-aside class="aside" width="200px">
        <el-menu :unique-opened ='true'
        :router="true">
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户管理</span>
            </template>
              <el-menu-item index="users">
                <i class="el-icon-user"></i>
                <span>角色管理</span>
              </el-menu-item>
             
          </el-submenu>  
          <!-- 2 -->
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-star-off"></i>
              <span>权限管理</span>
            </template>
              <el-menu-item index="1-1">
                <i class="el-icon-star-on"></i>
                <span>权限列表</span>
              </el-menu-item>
              <el-menu-item index="1-2">
                <i class="el-icon-star-on"></i>
                <span>角色列表</span>
              </el-menu-item>
          </el-submenu>  
          <!-- 3 -->
           <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-present"></i>
              <span>商品管理</span>
            </template>
              <el-menu-item index="1-1">
                <i class="el-icon-location"></i>
                <span>商品参数</span>
              </el-menu-item>
              <el-menu-item index="1-2">
                <i class="el-icon-location"></i>
                <span>商品列表</span>
              </el-menu-item>
              <el-menu-item index="1-2">
                <i class="el-icon-location"></i>
                <span>商品分类</span>
              </el-menu-item>
          </el-submenu>  
          <!-- 4 -->
          <el-submenu index="4">
            <template slot="title">
              <i class="el-icon-collection"></i>
              <span>订单管理</span>
            </template>
              <el-menu-item index="1-1">
                <i class="el-icon-location"></i>
                <span>订单列表</span>
              </el-menu-item>
             
          </el-submenu>  
          <!-- 5 -->
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-s-data"></i>
              <span>数据统计</span>
            </template>
              <el-menu-item index="1-1">
                <i class="el-icon-location"></i>
                <span>数据报表</span>
              </el-menu-item>
             
          </el-submenu>  
        </el-menu>
      </el-aside>
      <el-main class="main">
        <!-- 在这里渲染导航栏组件内容 -->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  // beforeCreate(){
  //   // 获取token,验证是否是用户登录
  //   // 1.获取token
  //   const token  = localStorage.getItem('token')
  //   // 2.判断是否有token
  //   // 没有就重定向到login页面
  //   // if(!token){
  //   //   this.$router.push({name : 'login'})
  //   // }
  //   // 如果有，就继续渲染
  // }
  methods:{
    loginout(){
      // 清楚token
      // token.clear();
      // 提示退出成功
      this.$message.success("退出成功")
      // 路由跳转到登录页
      this.$router.push({name: 'login'})
    }
  }
};
</script>

<style>
.container {
  height: 100%;
}

.header {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

.middle {
  line-height: center;
  padding-bottom: 5%;
  font-size: 25px;
  font-weight: bold;
}

.loginout {
  text-align: center;
  line-height: 60px;
  text-decoration: none;
}
</style>